#include <stdio.h>
#include <string.h>

int main(void){
  char *path = "io.txt";
  FILE *file = fopen(path,"a+");
  if(file==NULL){
    printf("文件不存在\n");
  }else{
    printf("文件打开成功\n");
  }
  // 向文件写入字符
  char words[]="hello world\r\n";
  int res=0;
  res = fputs(words,file);
  if(res==EOF){
    printf("文件写入失败\n");
  }else{
    printf("文件写入成功\n");
  }
  
  res = fclose(file);
  if(res!=0){
    printf("文件关闭失败\n");
    return -1;
  }
  printf("文件关闭成功\n");
  return 0;
}
